home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 February / PCWorld_2007-02_cd.bin / domacnost a kancelar / avedesk / AveDesk13.exe / Effects / Slide.effectlet < prev   
Extensible Markup Language  |  2005-03-15  |  7KB  |  271 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <effectlet>
  3.     <info>
  4.         <name>Slide Effect Script</name>
  5.         <author>Dreadnaut</author>
  6.         <notes><![CDATA[ For bugs or anything else, contact me at dreadnaut@despammed.com ]]></notes>
  7.         <version>0.0.6</version>
  8.     </info>
  9.     <settings>
  10.         <param name="Debug" type="Boolean" defval="False"/>
  11.     </settings>
  12.  
  13.     <preferences>
  14.  
  15.     <preference name="HorizontalMovement" type="range"   defval="0" min="-200" max="200">
  16.     Horizontal sliding of the desklet, expressed as a % of its width (Negative means left, positive right)
  17.         </preference>
  18.     <preference name="VerticalMovement" type="range"   defval="75" min="-200" max="200">
  19.     Vertical sliding of the desklet, expressed as a % of its height (Negative means up, positive down)
  20.         </preference>
  21.     <preference name="Smoothness" type="range"   defval="75" min="0" max="100">
  22.     Sets the smoothness of the animation
  23.         </preference>
  24.     <preference name="Speed" type="range"   defval="5" min="1" max="9">
  25.     Sets the speed of the slide effect
  26.         </preference>
  27.     <preference name="Delay" type="range"   defval="3" min="0" max="10">
  28.     Sets the delay (in seconds) after the desklet will start to slide back to its original position.
  29.     If WaitForMouseOut is set, the countdown will start after the mouse as left the desklet
  30.         </preference>
  31.     <preference name="StopOnMouseOut" type="range"  defval="1" min="0" max="1">
  32.     If set, leaving the desklet while it's sliding will cause it to slide back to its original position
  33.         </preference>
  34.     <preference name="RebounceOnMouseIn" type="range"  defval="1" min="0" max="1">
  35.     If set, the desklet will slide out again if touched while sliding back
  36.         </preference>
  37.     <preference name="WaitForMouseOut" type="range"   defval="1" min="0" max="1">
  38.     If set, the desklet will wait for the mouse to leave its area before sliding back (eventually after Delay seconds)
  39.         </preference>
  40.  
  41.     </preferences>
  42.  
  43.     <images>
  44.     </images>
  45.  
  46.     <script engine="vbScript"><![CDATA[
  47.  
  48.     Dim Counter
  49.     Dim StartTop, StartLeft
  50.     Dim EndTop, EndLeft
  51.     Dim HMov, VMov, Step
  52.     Dim TickRate
  53.     Dim State
  54.     Dim PrefChange
  55.     Dim isOver
  56.  
  57.     'These routines are the optional ones called by the framework
  58.     Sub OnCreate()
  59.     'Init
  60.     StartTop = Desklet.top
  61.     StartLeft = Desklet.left
  62.     Reset()
  63.     
  64.     'Default preferences
  65.     HorizontalMovement = 0
  66.     VerticalMovement = 75
  67.     Smoothness = 75
  68.     Speed = 5
  69.     Delay = 3
  70.     StopOnMouseOut = 1
  71.     RebounceOnMouseIn = 1
  72.     WaitForMouseOut = 1
  73.  
  74.         'And Reading overwrites them with some previous user changes
  75.         Preferences.ReadAll()
  76.     Evaluate()
  77.     End Sub
  78.  
  79.     Sub OnMouseOn()
  80.     If State = 0 Then
  81.         StartLeft = Desklet.left
  82.         StartTop = Desklet.top
  83.         EvaluatePosition()
  84.     End If
  85.     If PrefChange = true Then
  86.         Evaluate()
  87.     End If
  88.  
  89.     If (State = 0) Or ( (State = 2) And (RebounceOnMouseIn) ) Then
  90.         State = 1
  91.         Ticker.Interval = TickRate
  92.         Ticker.Enabled = True
  93.     End If
  94.  
  95.     If (State = 3) And (WaitForMouseOut = 1) Then
  96.         Ticker.Enabled = false
  97.     End If
  98.     isOver = true
  99.     End Sub
  100.  
  101.     Sub OnMouseout()
  102.     If (State = 1) And (StopOnMouseOut = 1) Then
  103.         State = 2
  104.     End If
  105.     If (State = 3) And (WaitForMouseOut = 1) Then
  106.         If Delay = 0 Then
  107.             State = 2
  108.             Ticker.Interval = TickRate
  109.         Else 
  110.             Counter = Delay -1
  111.             Ticker.Interval = 1000
  112.         End If
  113.         Ticker.Enabled = true
  114.     End If
  115.     isOver = false
  116.     End Sub
  117.  
  118.     'Function OnBeforeDraw(IsMouseOn, IsSelected, IsPreview)
  119.     'End Function
  120.  
  121.     'Function OnAfterDraw(IsMouseOn, IsSelected, IsPreview)
  122.     'End Function
  123.     
  124.     Sub OnSave()
  125.         Preferences.SaveAll 
  126.     End Sub
  127.  
  128.     'Optional. Indicates a preference change
  129.     Function OnPreferenceChange(Preference, oldValue, newValue)
  130.     Reset()
  131.     PrefChange = true
  132.     End Function
  133.  
  134.     Sub Reset()
  135.     Ticker.Enabled = false
  136.     state = 0
  137.     isOver = false
  138.     Desklet.move StartLeft, StartTop
  139.     End Sub
  140.  
  141.     Sub Evaluate()
  142.     EvaluatePosition()
  143.  
  144.     'tickrate in [50 + 0 .. 50 + 200]
  145.     TickRate = 50 + cint(200 * (100 - Smoothness) / 100)
  146.     Step = 11 - Speed
  147.  
  148.     PrefChange = false
  149.     End Sub
  150.  
  151.     Sub EvaluatePosition()
  152.     EndLeft = StartLeft + cint(Desklet.width * HorizontalMovement / 100)
  153.     EndTop = StartTop + cint(Desklet.height * VerticalMovement / 100)
  154.     End Sub
  155.  
  156.     'You can only have 1 Ticker per effectlet
  157.     'The OnTimer method is shielded against multiple entrance recursion
  158.     Sub OnTimer()
  159.     If State = 1 Then
  160.         If Desklet.left <> EndLeft Then
  161.             HMov = cint((EndLeft - Desklet.left)/abs(EndLeft - Desklet.left)) + cint((EndLeft - Desklet.left) / Step)
  162.         Else
  163.             HMov = 0
  164.         End If
  165.  
  166.         If Desklet.top <> EndTop Then
  167.             VMov = cint((EndTop  - Desklet.top )/abs(EndTop  - Desklet.top )) + cint((EndTop - Desklet.top) / Step)
  168.         Else
  169.             VMov = 0
  170.         End If
  171.     End If
  172.  
  173.     If State = 2 Then
  174.         If Desklet.left <> StartLeft Then
  175.             HMov = cint((StartLeft - Desklet.left)/abs(StartLeft - Desklet.left)) + cint((StartLeft - Desklet.left) / Step)
  176.         Else
  177.             HMov = 0
  178.         End If
  179.  
  180.         If Desklet.top <> StartTop Then
  181.             VMov = cint((StartTop - Desklet.top)/abs(StartTop - Desklet.top)) + cint((StartTop - Desklet.top) / Step)
  182.         Else
  183.             VMov = 0
  184.         End If
  185.     End If
  186.  
  187.     If (State = 1) Or (State = 2) Then
  188.         If (HMov <> 0) Or (VMov <> 0) Then
  189.             Desklet.Move Desklet.Left + HMov, Desklet.Top + VMov
  190.         Else
  191.             If State = 1 Then
  192.                 Desklet.Move EndLeft, EndTop
  193.                 State = 3
  194.                 If (WaitForMouseOut = 0) Or (isOver = false) Then
  195.                     If Delay = 0 Then
  196.                         State = 2
  197.                         Ticker.Interval = TickRate
  198.                     Else
  199.                         Counter = Delay -1
  200.                         Ticker.Interval = 1000
  201.                     End If
  202.                     Ticker.Enabled = true
  203.                 Else
  204.                     Ticker.Enabled = false
  205.                 End If
  206.             Else
  207.                 Reset()
  208.             End If
  209.         End If
  210.     Else
  211.         If State = 3 Then
  212.             If Counter > 0 Then
  213.                 Counter = Counter - 1
  214.             Else
  215.                 State = 2
  216.                 Ticker.Interval = TickRate
  217.                 Ticker.Enabled = true
  218.             End If
  219.         End If
  220.     End If
  221.  
  222.     'Desklet.Redraw()
  223.     End Sub
  224.  
  225.     'Optional calls that we don't need for this script:
  226.  
  227.     'Sub OnSelect()   
  228.     'End Sub
  229.  
  230.     'Sub OnDeselect()   
  231.     'End Sub
  232.  
  233.     'Sub OnShow()         
  234.     'End Sub
  235.  
  236.     'Sub OnHide()         
  237.     'End Sub
  238.  
  239.     'Sub OnConfigure() 
  240.         'the configuration dialog with default UI for
  241.         'XML preferences will be shown.
  242.         'An additional dialog designer is on its way. It will
  243.         'extend the available default preferences of type:
  244.         ' - slider, checkbox, combobox (builtin, v. 1.1, free on form with v. 1.2)
  245.         ' - textbox, file browser, favorites URL (builtin and free on form, v. 1.2)
  246.         ' - Any ocx (external, only free on form, v. 1.2)
  247.     'End Sub
  248.  
  249.     Sub OnStartMove()
  250.     Reset()
  251.     End Sub
  252.  
  253.     Sub OnEndMove()
  254.     StartTop = Desklet.top
  255.     StartLeft = Desklet.left
  256.     EvaluatePosition()
  257.     End Sub
  258.  
  259.     'Sub OnLeftClick()  
  260.     'End Sub
  261.  
  262.     'Sub OnRightClick()
  263.     'End Sub
  264.  
  265.     'Sub OnDestroy
  266.     'End Sub
  267.  
  268.  
  269.     ]]></script>
  270. </effectlet>
  271.